﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Linq;
using WPFExcelReport.Helpers;
using System.Windows.Input;
using System.Windows.Controls;
namespace WPFExcelReport
{
    /// <summary>
    /// 专用于布卷剪布
    /// </summary>
    public partial class TWBBPRN : UIWBBST
    {
        #region ==WBEWMPOS===========
        public static readonly DependencyProperty WBEWMPOSProperty = DependencyProperty.Register("WBEWMPOS",
            typeof(string), typeof(TWBBPRN),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWBEWMPOSChanged));
        public string WBEWMPOS
        {
            get
            {
                return (string)GetValue(WBEWMPOSProperty);
            }
            set
            {
                SetValue(WBEWMPOSProperty, value);
            }
        }
        private static void OnWBEWMPOSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TWBBPRN;
            if (src != null)
            {
                src.WBEWMPOS = (string)e.NewValue;
            }
        }
        #endregion
        #region ==WBEWBELEG===========
        public static readonly DependencyProperty WBEWBELEGProperty = DependencyProperty.Register("WBEWBELEG",
            typeof(string), typeof(TWBBPRN),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWBEWBELEGChanged));
        public string WBEWBELEG
        {
            get
            {
                return (string)GetValue(WBEWBELEGProperty);
            }
            set
            {
                SetValue(WBEWBELEGProperty, value);
            }
        }
        private static void OnWBEWBELEGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TWBBPRN;
            if (src != null)
            {
                src.WBEWBELEG = (string)e.NewValue;
            }
        }
        #endregion
         VWBBEW WBW;
         ITXEXRPT ITXEXRPT;
        public TWBBPRN()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWBBST();
            this.DataContext = MV;
            InitializeComponent();
            ITXEXRPT = new WPFExcelReport.ITXEXRPT();
            ITXEXRPT.Root = "C:\\IntexReport";
            ITXEXRPT.strCompany = app.company;
            ITXEXRPT.PrintType = "OpenExcel";
            WBW = new VWBBEW();
            MESSAGES += "QINEWWB;";
            WBEWBELEG = "342450";
            WBEWMPOS = app.TERMNO.Trim();
        }
        
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void OnWorkflowIDChange(MessageEventArgs e)
        {
            base.OnWorkflowIDChange(e);
            MessageInfo msg = e.Info;
            string task = msg.MSGTYPE;
            switch (task)
            {
                case "QINEWWB":
                    WBEWMPOS = msg.P1;
                    TMV.QINEWWB(msg);
                    break;
            }
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }
       
        public  override void PrintCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            TMV.PrintWB(TMV.SetProd); 
        }  
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            TMV.QINEWWB(null);
            base.QueryCommand(sender, e);
        } 
    }
}
